package vn.edu.ptithcm.pim.dao;

import vn.edu.ptithcm.pim.dom.RoleApplicationPermission;
import vn.edu.ptithcm.pim.dom.RoleApplicationPermissionId;

import java.util.List;

import org.hibernate.LockMode;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

@SuppressWarnings({ "rawtypes" })
public class RoleApplicationPermissionDao extends HibernateDaoSupport {

	public void save(RoleApplicationPermission roleApplicationPermission) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().save(roleApplicationPermission);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void saveOrUpdate(RoleApplicationPermission roleApplicationPermission) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().saveOrUpdate(roleApplicationPermission);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void lock(RoleApplicationPermission roleApplicationPermission) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().lock(roleApplicationPermission,
					LockMode.NONE);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void delete(RoleApplicationPermission roleApplicationPermission) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().delete(roleApplicationPermission);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public RoleApplicationPermission merge(
			RoleApplicationPermission roleApplicationPermission) {
		try {
			return (RoleApplicationPermission) getHibernateTemplate().merge(
					roleApplicationPermission);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public RoleApplicationPermission findById(RoleApplicationPermissionId id) {
		try {
			return (RoleApplicationPermission) getHibernateTemplate().get(
					RoleApplicationPermission.class, id);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public List findByExample(
			RoleApplicationPermission roleApplicationPermission) {
		try {
			return getHibernateTemplate().findByExample(
					"RoleApplicationPermission", roleApplicationPermission);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public List getAll() {
		try {
			return getHibernateTemplate().loadAll(
					RoleApplicationPermission.class);
		} catch (RuntimeException re) {
			throw re;
		}
	}

}
